package com.hp.dao;

import java.util.List;

import org.apache.ibatis.annotations.Delete;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;
import org.apache.ibatis.annotations.Update;

import com.hp.model.Order;

public interface OrderDao {

	//查询全部订单
	@Select("select * from orders")
	List<Order> findAllOrder();
	
	//分页查询
	@Select("select *from orders limit #{m},#{pageSize}")
	List<Order> findOrderBypage(@Param("pageSize") Integer pageSize,@Param("m") Integer m);
	
	//获取全部页数
	@Select("select count(*) from orders")
	Integer count();
	
	//未付款
	@Select("select *from orders inner join users on orders.user_id=users.id where status=1")
	List<Order> nopayOrder();
	
	 //已付款
	  @Select("select *from orders inner join users on orders.user_id=users.id where status=2")
	  List<Order> payOrder();	 
	  
	  //配送中	  
	  @Select("select *from orders inner join users on orders.user_id=users.id  where status=3") 
	  List<Order> Ordering();
	  
	  //已完成	
	  @Select("select *from orders inner join users on orders.user_id=users.id where status=4")
	  List<Order> finishOrder();
	 
	  
	  //删除
	  @Delete("delete from orders where id=#{id}")
	  Integer delorder(@Param("id") int id);

	  //发货
	  @Update("update orders set status=3 where id=#{id}")
	  Integer orderUpdate(@Param("id") Integer id);	 
	  
	  //完成
	  @Update("update orders set status=4 where id=#{id}")
	  Integer completeorder(@Param("id") Integer id);	 
}
